package com.trumeen.immichgallery.ui.components

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.Error
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material.icons.filled.Warning
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.trumeen.immichgallery.viewmodel.ConnectionStatus

@Composable
fun ServerStatusIndicator(
    status: ConnectionStatus,
    modifier: Modifier = Modifier
) {
    Box(
        modifier = modifier.size(40.dp),
        contentAlignment = Alignment.Center
    ) {
        when (status) {
            ConnectionStatus.NOT_CONNECTED -> {
                Icon(
                    imageVector = Icons.Default.Warning,
                    contentDescription = "未连接",
                    tint = MaterialTheme.colorScheme.error
                )
            }
            ConnectionStatus.CONNECTING -> {
                CircularProgressIndicator(
                    modifier = Modifier.size(24.dp),
                    strokeWidth = 2.dp,
                    color = MaterialTheme.colorScheme.primary
                )
            }
            ConnectionStatus.CONNECTED -> {
                Icon(
                    imageVector = Icons.Default.CheckCircle,
                    contentDescription = "已连接",
                    tint = MaterialTheme.colorScheme.primary
                )
            }
            ConnectionStatus.FAILED -> {
                Icon(
                    imageVector = Icons.Default.Error,
                    contentDescription = "连接失败",
                    tint = MaterialTheme.colorScheme.error
                )
            }
        }
    }
}